//
//  L2MutableArray.m
//  Lesson2
//
//  Created by Alexander Trifonov on 20.04.12.
//  Copyright (c) 2012 fgengine@gmail.com. All rights reserved.
//

#import "L2MutableArray.h"

@implementation L2MutableArray

- (void) execute
{
    NSMutableArray *a1 = [NSMutableArray arrayWithCapacity:10];
    NSMutableArray *a2 = [[NSMutableArray alloc] initWithCapacity:10];
    [a2 release];
    
    NSLog(@"-L2MutableArray-------------------------");
    
    [a1 addObject:@"Martin"];
    [a1 addObject:@"Cyndi"];
    [a1 addObject:@"Hyman"];    
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    NSArray *array = [NSArray arrayWithObjects:@"Stefan", @"Shane", @"Ray", @"Rudy", @"Piter", @"Oleg", @"Vladimir", nil];
    [a1 addObjectsFromArray:array];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 insertObject:@"Ivan" atIndex:2];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 removeLastObject];
    [a1 removeObject:@"Ivan"];
    [a1 removeObjectAtIndex:3];
    [a1 removeObjectIdenticalTo:@"Ray"];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    NSArray *objectsToRemove = [NSArray arrayWithObjects:@"Martin", @"Rudy", nil];
    [a1 removeObjectsInArray:objectsToRemove];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 removeObjectsInRange:NSMakeRange(0, 2)];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 removeAllObjects];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    NSArray *newArray = [NSArray arrayWithObjects:@"Lida", @"Dasha", @"Vera", nil];
    [a1 setArray:newArray];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 replaceObjectAtIndex:1 withObject:@"Olga"];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
    
    [a1 exchangeObjectAtIndex:0 withObjectAtIndex:2];
    NSLog(@"%@", a1);
    
    NSLog(@"----------------------------------------");
}

@end
